import 'package:flutter/material.dart';

/// @date 2020/08/06  10:59
/// @author 程志强
/// @des 缩放

class GestureScale extends StatefulWidget {
  @override
  _GestureScaleState createState() => _GestureScaleState();
}

class _GestureScaleState extends State<GestureScale> {
  // 通过修改图片宽度达到缩放效果
  double _width = 300.0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("缩放"),
        ),
        body: Center(
          child: GestureDetector(
            //指定宽度，高度自适应
            child: Image.network(
                "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2534506313,1688529724&fm=26&gp=0.jpg",
                width: _width),
            onScaleUpdate: (ScaleUpdateDetails details) {
              setState(() {
                //缩放倍数在0.8到10倍之间
                _width = 200 * details.scale.clamp(.8, 10.0);
              });
            },
          ),
        ));
  }
}
